<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>情况二 - 外边距margin重叠（margin合并）</title>
  <style>
    /* 情况二: 兄弟之间的元素, 垂直方向的 “margin-bottom”和“margin-top”会合并为单个边距... */
    .box {
      width: 100px;
      height: 100px;
      background: red;
    }

    .container {
      overflow: hidden;
    }
  </style>
</head>

<body>
  <!-- <div class="box" style="margin-bottom: 100px;">
  </div>
  <div class="box" style="margin-top: 100px;">
  </div> -->

  <!-- 解决办法 ->每个元素放置不同的BFC中, 通过 “overflow: hidden;” ->触发BFC -->
  <div class="container">
    <div class="box" style="margin-bottom: 100px;">
    </div>
  </div>
  <div class="container">
    <div class="box" style="margin-top: 100px;">
    </div>
  </div>
</body>

</html>